package com.blacksee.bluetoothpoker.network.messages;

import com.blacksee.bluetoothpoker.logic.net.mypapit.java.StringTokenizer;

public class CardsMessage implements NetMessage {

	private int senderID;
	
	/**cards should be presented as string like this:
	 * King of Clubs, Ten of Spades and 7 of Hearts = kcts7h
	 * @see Cards
	*/
	private String cards = "";
	
	private int numCards;
	
	public CardsMessage() {
		
	}
	
	public CardsMessage(int senderID, int numCards){
		this.numCards = numCards;
		this.senderID = senderID;
	}
	
	public CardsMessage(int senderID, String cards){
		this.cards = cards;
		this.senderID = senderID;
	}
	
	public int getSenderID() {
		return senderID;
	}

	public String getCards() {
		return cards;
	}

	public void setCards(String cards) {
		this.cards = cards;
	}

	public void parseParameters(String message) {
		// TODO Auto-generated method stub
		StringTokenizer tok = new StringTokenizer(message,"*");
		String messageHead = tok.nextToken();
		if (tok.hasNext()) {
			this.senderID = Integer.parseInt(tok.nextToken());
		}
		if (tok.hasNext()) {
			this.numCards = Integer.parseInt(tok.nextToken());
		}
		if (tok.hasNext()) {
			this.cards = tok.nextToken();
		}
	}

	public String GetMessageString() {
		String text = "RECEIVE_CARD*";
		text += senderID + "*";
		text += numCards + "*";
		text += cards;
		return text;
	}

	public int getNumCards() {
		return numCards;
	}
	
}
